import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { h } from 'vue';
import { Input,Select } from 'ant-design-vue';
import {tags} from "@/views/demo/page/account/center/data";
//列表数据
export const columns: BasicColumn[] = [
/*   {
    title: '家长pin',
    align:"center",
    dataIndex: 'pin'
   },*/
   {
    title: '家长姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '手机号',
    align:"center",
    dataIndex: 'mobile'
   },
   {
    title: '通话类型',//1-sim卡，2-腾讯视频云 ，3-阿里视频云，4-钉钉，5-VOIP，6-微信,默认1',
    align:"center",
    dataIndex: 'numberTypes',
     customRender:({ value, record })=>{
       let str = value;
       let arr = [];
       if(str) {
         arr = str.split(",");
         console.log(arr[0]);
         console.log(arr[1]);
       }
       let re = "";
       for(let i in arr){
         if(arr[i]==1){
           re = re+"sim卡"+",";
         }
         if(arr[i]==2){
           re = re+"腾讯视频云"+",";
         }
         if(arr[i]==3){
           re = re+"阿里视频云"+",";
         }
         if(arr[i]==4){
           re = re+"钉钉"+",";
         }
         if(arr[i]==5){
           re = re+"VOIP"+",";
         }
         if(arr[i]==6){
           re = re+"微信";
         }
       }
       return re;
     },
   },
   {
    title: '状态',//0-禁用，1-正常；默认1',
    align:"center",
    dataIndex: 'status',
    customRender:({value,record})=>{
      return value==0?"禁用":value==1?"正常":"";
    }
   },
/*   {
    title: '学校组织ID',
    align:"center",
    dataIndex: 'organizationId'
   },
   {
    title: '家长id',
    align:"center",
    dataIndex: 'parentId'
   },*/
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '家长姓名',
    field: 'name',
    component: 'JInput',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
/*  {
    label: '家长pin',
    field: 'pin',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入家长pin!'},
          ];
     },
  },*/
  {
    label: '家长姓名',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入家长姓名!'},
          ];
     },
    dynamicDisabled:true,
  },
  {
    label: '手机号',
    field: 'mobile',
    component: 'Input',
    dynamicDisabled:true,
  },
  {
    label: '通话类型',//1-sim卡，2-腾讯视频云 ，3-阿里视频云，4-钉钉，5-VOIP，6-微信,默认1',
    field: 'numberTypes',
    component: 'Select',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入1-sim卡，2-腾讯视频云 ，3-阿里视频云，4-钉钉，5-VOIP，6-微信,默认1!'},
          ];
     },
    componentProps:{
      mode:"tags"
    },
    render:({ model, field })=>{
      let str = model[field];
      let arr = [];
      if(str) {
        arr = str.split(",");
        console.log(arr[0]);
        console.log(arr[1]);
      }
      let re = "";
      for(let i in arr){
        if(arr[i]==1){
          re = re+"sim卡"+",";
        }
        if(arr[i]==2){
          re = re+"腾讯视频云"+",";
        }
        if(arr[i]==3){
          re = re+"阿里视频云"+",";
        }
        if(arr[i]==4){
          re = re+"钉钉"+",";
        }
        if(arr[i]==5){
          re = re+"VOIP"+",";
        }
        if(arr[i]==6){
          re = re+"微信";
        }
      }
      return h(Select, {
        value: re,
        disabled:true,
        style: { width: '100%' },
      });
    },


  },
  {
    label: '状态',//0-禁用，1-正常；默认1',
    field: 'status',
    component: 'Select',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入0-禁用，1-正常；默认1!'},
          ];
     },
    componentProps:{
      options:[{label:"禁用",value:0},{label:"正常",value:1},]
    },
    dynamicDisabled:true,
  },
 /* {
    label: '学校组织ID',
    field: 'organizationId',
    component: 'InputNumber',
  },
  {
    label: '家长id',
    field: 'parentId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入家长id!'},
          ];
     },
  },*/
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show:false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  pin: {title: '家长pin',order: 0,view: 'text', type: 'string',},
  name: {title: '家长姓名',order: 1,view: 'text', type: 'string',},
  mobile: {title: '手机号',order: 2,view: 'text', type: 'string',},
  numberTypes: {title: '1-sim卡，2-腾讯视频云 ，3-阿里视频云，4-钉钉，5-VOIP，6-微信,默认1',order: 3,view: 'text', type: 'string',},
  status: {title: '0-禁用，1-正常；默认1',order: 4,view: 'number', type: 'number',},
  organizationId: {title: '学校组织ID',order: 5,view: 'number', type: 'number',},
  parentId: {title: '家长id',order: 6,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
